<template>
	<!-- 提现 -->
	<view class="tx" v-if="time>time2">
		<view class="weix">
			<view class="text">选择提现方式</view>
			<view class="weixinzf flex-cb">
				<view class="weixin_img flex align-center">
					<view class="cuIcon-weixin flex-c"></view>
					<text>微信支付</text>
				</view>
				<text class="cuIcon-roundcheckfill" v-if="ischoice" @click="ischoice = 0"></text>
				<text class="cuIcon-round" v-else @click="ischoice = 1"></text>
			</view>
			<view class="weixinzf flex-cb yhk" v-if="banklist.length > 0">
				<view class="weixin_img flex align-center">
					<image src="/static/yhk.png" mode="" style="width: 50rpx;height: 50rpx;"></image>
					<text>银行卡</text>
				</view>
				<text class="cuIcon-roundcheckfill" v-if="!ischoice" @click="ischoice = 1"></text>
				<text class="cuIcon-round" v-else @click="ischoice = 0"></text>
			</view>
			<view class="addbank flex-cb" v-if="banklist.length == 0">
				<view @click="isshow = 1">添加银行卡</view>
				<!-- <navigator url="./mybank">我的银行卡</navigator> -->
			</view>
		</view>
		
		<view class="weixin_monye weix">
			<view class="text">提现金额</view>
			<view class="input flex align-center">
				<text>￥</text>
				<input type="digit" placeholder="请输入想要提现的金额" v-model="amount" placeholder-style="color:#ccc;font-size:28rpx">
			</view>
			<view class="solid"></view>
			<view class="ft flex-cb">
				<text>{{oney}}</text>
				<text class="qbtx" @click="amount = oney">全部提现</text>
			</view>
		</view>
		<view class="button flex-c" @click="qrue">提交</view>
		<view class="modal_view foot flex-c" v-if="isshow" >
			<view class="modal_div">
				<view class="title">添加银行卡</view>
				<view class="name flex-cb">
					<input type="number" placeholder="请输入银行卡" v-model="cart"  />
				</view>
				<view class="numbar name flex align-center">
					<input type="text" placeholder="请输入持卡人姓名" v-model="name" >
				</view>
				<view class="numbar name flex align-center">
					<input type="text" placeholder="请输入银行名称" v-model="bank_name" >
				</view>
				<view class="button_min flex-cb">
					<view class="left" @click="isshow=0">取消</view>
					<view class="center"></view>
					<view class="right" @click="addBank">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isshow:0,
				ischoice:1,//1微信 0银行卡
				banklist:[],
				amount:'',
				cart:'',
				name:'',
				bank_name:'',
				oney:'',
				user:'',
				time:'',
				time2:''
			};
		},
		onLoad(e){
			console.log(e);
			this.time = Date.parse(new Date()) /1000
			this.time2 = this.$time
			if(this.time<this.time2){
				uni.setNavigationBarTitle({
					title:'详情',
					complete(res) {
						console.log(res,'12563');
					}
				})
			}
			this.$api.user({},true).then(res=>{
				if(res.code == 200001){
					this.user = res.data
					this.oney = this.user.commission
					console.log(res);
				}
			})
			
			
		},
		onShow(){
			this.getbank()
		},
		methods:{
			getbank(){
				this.$api.user_bank().then(res=>{
					console.log(res);
					this.banklist = res.data
				})
			},
			qrue(){
				if(this.amount <= 0){
					return
				}
				if(this.ischoice == 1){//微信提现
					this.$api.user_withdraw({
						method:1,
						amount:this.amount,
						bank_id:null
					},1).then(res=>{
						if(res.code == 200001){
							uni.showToast({
								icon:"none",title:"提交成功"
							})
							uni.navigateBack({	
								delta: 1
							})
						}
					})
				}else{
					this.$api.user_withdraw({//银行卡提现
						method:2,
						amount:this.amount,
						bank_id:this.banklist[0].id
					},true).then(res=>{
						if(res.code == 200001){
							uni.showToast({
								icon:"none",title:"提交成功"
							})
							uni.navigateBack({
								delta: 1
							})
						}
					})
				}
			},
			addBank(){
				this.$api.user_add_bank({
					bank_name:this.bank_name,
					bank_card_number:this.cart,
					bank_card_username:this.name,
				},1).then(res=>{
					if(res.code == 200001){
						this.getbank()
						this.isshow = 0
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.tx{padding-top: 50rpx;}
.yhk{
	margin-top: 55rpx;
}
.addbank{
	color: #1CD699;
	font-size: 32rpx;
	height: 45rpx;
	margin-top: 41rpx;
}
.weix{
	width: 690rpx;
	height: auto;
	background: #FFFFFF;
	box-shadow: 0px 0px 20rpx 1rpx rgba(71,71,71,0.09);
	border-radius: 20rpx;
	margin: auto;
	padding: 34rpx 40rpx 38rpx 38rpx;
	.text{
		color: #333;
		font-size: 34rpx;
		font-weight: bold;
		margin-bottom: 39rpx;
	}
	.weixinzf{
		.weixin_img{
			.cuIcon-weixin{
				width: 50rpx;
				height: 50rpx;
				font-size: 36rpx;
				padding-bottom: 5rpx;
				color: #FFFFFF;
				background: #3EB135;
				border-radius: 50%;
			}
			text{
				font-size: 32rpx;
				margin-left: 19rpx;
			}
		}
		.cuIcon-roundcheckfill,.cuIcon-round{
			font-size: 44rpx;
			color: #1CD699;
		}
		.cuIcon-round{
			color: #CCCCCC;
		}
	}
}
.weixin_monye{
	width: 690rpx;
	height: 460rpx;
	background: #FFFFFF;
	box-shadow: 0px 0px 20rpx 1rpx rgba(71,71,71,0.09);
	border-radius: 20rpx ;
	margin: 30rpx auto;
	padding-right: 30rpx;
	.text{
		margin-bottom: 55rpx;
	}
	.input{
		text{
			font-size: 34rpx;
		}
		input{
			width: 280rpx;
			height: 40rpx;
			margin-left: 12rpx;
		}
	}
	.solid{
		width: 570rpx;
		margin: auto;
		margin-top: 33rpx;
	}
	.ft{
		padding-top: 11rpx;
		text-align: right;
		font-size: 26rpx;
		font-weight: bold;
		text{
			margin-left: 20rpx;
		}
		.qbtx{
			color: #1CD699;
			// color: #999999;
		}
	}
}
.button{
	width: 648rpx;
	height: 80rpx;
	background: #1CD699;
	border-radius: 10rpx;
	color: #FFFFFF;
	position: absolute;
	bottom: 157rpx;
	left: 51rpx;
	z-index: 0;
}
.foot{
	position: fixed;
	z-index: 2;
	.modal_div{
		width: 532rpx;
		min-height: 420rpx;
		background: #F3F3F3;
		border-radius: 10rpx;
		.title{
			color: #070707;
			font-weight: 500;
			margin-top: 32rpx;
			margin-bottom: 52rpx;
			text-align: center;
		}
		.name{
			width: 472rpx;
			height: 62rpx;
			background: #F3F3F3;
			border-radius: 10rpx;
			border: 1rpx solid #DADADA;
			margin: auto;
			padding: 0 23rpx 0 14rpx;
			input{
				width: 100%;
			}
		}
		.numbar{
			margin-top: 36rpx;
		}
		.button_min{
			margin-top: 40rpx;
			height: 78rpx;
			border-top: solid 1rpx #DADADA;
			.center{
				width: 1rpx;
				height: 66rpx;
				background: #DADADA;
				border-radius: 1rpx;
			}
			.left,.right{
				flex: 1;
				// font-size: 26rpx;
				text-align: center;
			}
			.right{
				color: #1CD699;
			}
		}
	}
	
}
</style>
